//
// Created by fyniny on 12/23/18.
//

#pragma once
#include <map>
#include <list>
#include <iostream>

// 控制assert断言
#define NDEBUG
#define DEBUG
#ifdef DEBUG
#undef NDEBUG
#endif // DEBUG
#include <assert.h>
#include <string>


#ifdef  DEBUG__
// 输出提醒，用于测试
#define SHOW_WAKE std::cout << "\n--------------------------i am process " << getProcessID() << " an i am blocked---------------------\n"
#define SHOW_WAKE_2 std::cout << "\n------------------------i am process " << getProcessID() << " an i awake process" << base->getProcessID() <<"---------------------\n"
#else
#define SHOW_WAKE
#define SHOW_WAKE_2
#endif // DEBUG

#ifndef _PCB_
#define _PCB_

struct PCB
{
    int id;	// 进程标识符
    int status; // 进程状态

    PCB(int id, int status) {
        this->id = id;
        this->status = status;
    }
    PCB(){}
};

constexpr auto  PROCESS_EXECUTABLE = 0;		//	可执行状态
constexpr auto  PROCESS_WAIT_FULL_OUTPUT_BLOCK = 1;//	为等待状态1，表示请求输出块用完，请求输出的用户进程等待
constexpr auto  PROCESS_WAIT_EMPTY_OUTPUT_BLOCK = 2;//	等待状态2， 表示输出井空，SPOOLING输出进程等待;
constexpr auto  PROCESS_RESULT = 3;				//	结束态，进程执行完成
#endif // !_PCB_


#ifndef _REQBLOCK_
#define _REQBLOCK_
struct ReqBlock
{
    int req_name; // 进程名
    int length;	  // 输出长度
};
#endif // !_REQBLOCK_

#ifndef SYS_CONFIG
#define SYS_CONFIG
constexpr auto MAX_OUTPUT_CONTAINER = 20; // 最大输出，进程输出次数到达此阈值将终止运行
constexpr auto MAX_OUTPUT_BLOCK = 10; // 输入井的最大容量
#define list std::list
#define map std::map
#endif // !SYS_CONFIG


#ifndef _BUFFER_
#define _BUFFER_
namespace BUFFER {
    constexpr auto buf_size = 30;
    constexpr auto buf_sign = 11;
    class buffer
    {
    public:
        char buf[buf_size + buf_sign];
        buffer& operator<<(const char* str) ;
        buffer& operator<<(char ch) ;
        buffer();
        // 只能是0 ~ 9 的数字
        buffer& operator<<(int ch);

    public:
        virtual const char* getBuffer() const ;

    };
}

typedef BUFFER::buffer Buffer;
#endif